package com.iot08.api.service;

import com.iot08.common.entity.app.PxAdversterSlot;
import com.iot08.common.service.base.BaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

/**
 * @author cwj
 * @description
 * @date 2025/4/14 13:59
 **/
@Slf4j
@Service
public class PxAdversterSlotService extends BaseService<PxAdversterSlot> {

    /**
     * @description 根据广告位名字查询广告位
     * @author cwj
     * @param [name]
     * @return com.iot08.common.entity.app.PxAdversterSlot
     * @date @time 2025/4/14 14:06
     **/
    public PxAdversterSlot queryByName(String name) {
        Query query = new Query(Criteria.where("name").is(name).and("status").is(1)).limit(1);
        return this.findOne(query);
    }

    /**
     * @description 根据广告位编码查询广告位
     * @author cwj
     * @param [code]
     * @return com.iot08.common.entity.app.PxAdversterSlot
     * @date @time 2025/4/14 15:24
     **/
    public PxAdversterSlot queryByCode(String code) {
        Query query = new Query(Criteria.where("code").is(code).and("status").is(1)).limit(1);
        return this.findOne(query);
    }

}
